package com.example.twoscroolview.activity

import android.os.Bundle
import android.os.SystemClock
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.viewpager.widget.PagerAdapter
import com.example.twoscroolview.R
import kotlinx.android.synthetic.main.activity_swip_scroll.*

class SwipAndVpActivity : AppCompatActivity() {
    val list = mutableListOf<String>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_swip_scroll)
        initView()
    }

    private fun initView() {
        val tabs = listOf<String>("111", "222", "333", "4444")
        for (i in 0..7) {
            list.add("TwoScrollViewActivity------" + i)
        }
        swip.setOnRefreshListener {
            swip.postDelayed({
                swip.isRefreshing =false
            },2000)

        }
        viewpage2.adapter = object : PagerAdapter(){
            override fun getCount(): Int {
              return 4
            }

            override fun isViewFromObject(view: View, `object`: Any): Boolean {
                return view == `object`
            }

            override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
                container.removeView(`object` as View?)
            }
            override fun instantiateItem(container: ViewGroup, position: Int): Any {
                val tv = TextView(this@SwipAndVpActivity)
                tv.setText("instantiateItem----$position")
                container.addView(tv)
                return tv
            }

        }



    }
}